//
//  NYMyClassesViewController.m
//  NiuWaJiaoYu
//
//  Created by MinLison on 2018/1/7.
//  Copyright © 2018年 niuwaketang. All rights reserved.

#import "NYMyClassesViewController.h"
#import "NYPageViewController.h"
#import "NYMyClassListViewController.h"
@interface NYMyClassesViewController ()<WGPageViewControllerDelegate>
@property(nonatomic, strong) NYPageViewController *pageViewController;
@end

@implementation NYMyClassesViewController

- (void)viewDidLoad
{
        [super viewDidLoad];
        [self configPageViewController];
        [self reloadPageViewController];
}

- (void)configNavigationBar:(BaseNavigationBar *)navigationBar
{
        [super configNavigationBar:navigationBar];
        self.title = @"我的课程";
}

- (void)reloadPageViewController
{
        NSMutableArray <NSString *>*tmp = [NSMutableArray arrayWithArray:@[@"知识点",@"杯赛"]];
        self.pageViewController.segmentTitles = tmp;
        [self.pageViewController reloadData];
}

/// MARK: - PageViewController Delegate
- (NSInteger)countOfContentItems
{
        return self.pageViewController.segmentTitles.count;
}
- (UIViewController *)contentControllerAtIndex:(NSInteger)index
{
        NYMyClassListViewController *vc = [[NYMyClassListViewController alloc] init];
        vc.classesType = (NYMyClassesType)(index + 1);
        return vc;
}

- (void)configPageViewController
{
        self.pageViewController = [[NYPageViewController alloc] init];
        self.pageViewController.topSortViewHeight = __WGHeight(50);
        self.pageViewController.pageDelegate = self;
        self.pageViewController.topSortBottomLineColor = UIColorSeparator;
        self.pageViewController.segmentControl.segmentWidthStyle = HMSegmentedControlSegmentWidthStyleFixed;
        self.pageViewController.segmentControl.selectedTitleTextAttributes = @{
                                                                               NSForegroundColorAttributeName : UIColorHex(0x5396F7),
                                                                               NSFontAttributeName : WGSystem15Font,
                                                                               };
        self.pageViewController.segmentControl.titleTextAttributes = @{
                                                                       NSForegroundColorAttributeName : UIColorHex(0x333333),
                                                                       NSFontAttributeName : WGSystem15Font,
                                                                       };
        self.pageViewController.segmentControl.selectionIndicatorEdgeInsets = UIEdgeInsetsMake(0, -3, 0, -3);
        self.pageViewController.segmentControl.selectionIndicatorColor = UIColorHex(0x5396F7);
        self.pageViewController.segmentControl.segmentEdgeInset = UIEdgeInsetsMake(0, 10, 0, 10);
        
        [self.pageViewController willMoveToParentViewController:self];
        [self addChildViewController:self.pageViewController];
        self.controllerView.contentView = self.pageViewController.view;
        [self.pageViewController didMoveToParentViewController:self];
}


+ (NYViewControllerNavigationBarType)navigationBarType
{
        return NYViewControllerNavigationBarTypeBlue;
}
@end
